package com.example.rzprogram;

import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.widget.Button;
import android.widget.MediaController;
import android.widget.TextView;
import android.widget.VideoView;

import com.example.base.BaseActivity;
import com.example.bean.About;
import com.example.bean.AboutBean;
import com.example.network.ProtocolService;
import com.lidroid.xutils.ViewUtils;
import com.lidroid.xutils.exception.HttpException;
import com.lidroid.xutils.http.ResponseInfo;
import com.lidroid.xutils.http.callback.RequestCallBack;
import com.lidroid.xutils.view.annotation.ViewInject;
import com.lidroid.xutils.view.annotation.event.OnClick;

public class AboutActivity extends BaseActivity {

	@ViewInject(R.id.btn_menu)
	private TextView tv_menu;
	@ViewInject(R.id.btn_percenter)
	private Button percenter;
	@ViewInject(R.id.about_title)
	private TextView tv_title;
	@ViewInject(R.id.video)
	private VideoView videoView;
	@ViewInject(R.id.about_jieshao)
	private TextView tv_explain;
	
	private About data;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.activity_about);
		ViewUtils.inject(this);
		
		ProtocolService.about(new RequestCallBack<String>() {
			
			@Override
			public void onSuccess(ResponseInfo<String> arg0) {
				//数据解析
				AboutBean bean = com.alibaba.fastjson.JSONObject.parseObject(
						arg0.result, AboutBean.class);
				data = bean.getAboutUS();
				tv_title.setText(data.getAboutTitle());
				//视频网络播放
				Uri uri = Uri.parse(data.getAboutVideo());
				videoView.setMediaController(new MediaController(AboutActivity.this));    
				videoView.setVideoURI(uri);    
				videoView.start();    
				videoView.requestFocus(); 
				tv_explain.setText(data.getAboutDesp());
			}
			
			@Override
			public void onFailure(HttpException arg0, String arg1) {
				// TODO Auto-generated method stub
				
			}
		});
	}
	@OnClick({ R.id.btn_menu, R.id.btn_percenter})
	public void onCliecks(View v) {
		switch (v.getId()) {
		case R.id.btn_menu:
			//菜单
			break;
		case R.id.btn_percenter:
			 Intent intent = new Intent(AboutActivity.this,
			 MainActivity.class);
			 startActivity(intent);
			break;
		}
	}

}
